<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>修改学生信息</h1>
<div>
    <input type="text" v-model="emp.id" readonly>
    <input type="text" v-model="emp.name">
    <input type="text" v-model="emp.sal">
    <input type="text" v-model="emp.job">
    <input type="button" value="修改" @click="update()">
</div>

<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

<script>
    let v=new Vue({
        el:"body>div",
        data:{
            emp: {}
        },
        methods:{
            update(){
                //发出修改请求
                axios.post("/update",v.emp).then(function () {
                    //回到列表页面
                    location.href="/select.html";
                })
            }
        },
        created:function () {
            //得到地址栏中的id location.search得到地址栏中的参数
            let id=location.search.split("=")[1];
            console.log("id="+id);
            //发请求获取员工信息
            axios.get("/selectById?id="+id).then(function (response) {
                v.emp=response.data;
            })
        }
    })
</script>

</body>
</html>